package LeetCode;

public class LC_260_SingleNumberIII {

    public static void main(String[] args) {

    }

    static class Solution {
        public int[] singleNumber(int[] nums) {
            int AXORB = 0;
            for (int num : nums) AXORB ^= num;
            int bitFlag = (AXORB & (~(AXORB - 1)));
            int[] res = new int[2];
            for (int num : nums) {
                if ((num & bitFlag) == 0)
                    res[0] ^= num;
                else
                    res[1] ^= num;
            }
            return res;
        }
    }

}